import TimerBaseCommand from './timerBaseCommand';

class AddTimerCommand extends TimerBaseCommand {
  static CMD = 0x07;  // 添加定时事件命令

  /**
   * 创建添加定时命令
   * @param {Object} config - 定时配置
   */
  static createCommand(config) {
    const data = this.packTimeData(config);
    return this.packFrame(this.CMD, data);
  }

  /**
   * 解析添加定时响应
   * @param {Uint8Array} frame - 响应数据帧
   */
  static parseResponse(frame) {
    const parsed = this.parseBaseFrame(frame);
    if (!parsed || parsed.cmd !== this.CMD) return null;

    return {
      timerId: parsed.data[0]  // 返回新创建的定时器ID
    };
  }
}

export default AddTimerCommand; 